<% layout('/layouts/default.html', {title: '备品备件申领管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text('备品备件申领')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('test:componentApplication:edit')){ %>
					<a href="${ctx}/test/componentApplication/form" class="btn btn-default btnTool" title="${text('新增component_application')}"><i class="fa fa-plus"></i> ${text('申领')}</a>
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${componentApplication}" action="${ctx}/test/componentApplication/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label" hidden="hidden">${text('备品备件编号')}：</label>
					<div class="control-inline">
						<#form:input:hidden  path="componentCode" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('装配设备编号')}：</label>
					<div class="control-inline">
						<#form:input path="equipCode" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('申领人')}：</label>
					<div class="control-inline">
						<#form:input path="applicantCode" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('审批人')}：</label>
					<div class="control-inline">
						<#form:input path="approvalCode" maxlength="255" class="form-control width-120"/>
					</div>
				</div>

			<#form:input:hidden path="applySort" maxlength="11" class="form-control width-120"/>
			<#form:select:hidden path="status" dictType="sys_search_status" blankOption="true" class="form-control"/>
			<#form:input:hidden path="remarks" maxlength="500" class="form-control width-120"/>
			<#form:input:hidden path="applicationNumber" maxlength="11" class="form-control width-120"/>

				<div class="form-group">
					<label class="control-label">${text('申领原因')}：</label>
					<div class="control-inline">
						<#form:input path="applicationReason" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('申请时间')}：</label>
					<div class="control-inline">
						<#form:input path="applicationSubmitDate" class="form-control width-120"/>
					</div>
				</div>

				<#form:input:hidden path="applicationEndDate" class="form-control width-120"/>

				<div class="form-group">
					<label class="control-label">${text('申领状态')}：</label>
					<div class="control-inline" style="width:150px;">
						<#form:input path="applicationStatus" maxlength="1"  class="form-control width-120"/>
					</div>
				</div>



				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>


// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text('申请编号')}', name:'applicationCode', index:'a.application_code', width:180, align:"left", frozen:true, formatter: function(val, obj, row, act){
                if(row.applicationStatus == '0'){
                    row.applicationStatus = "待审核"
                }else if(row.applicationStatus == '1'){
                    row.applicationStatus = "审核通过";
                    return '<p>'+(val||row.applicationCode)+'</p>';
                }else{
                    row.applicationStatus = "驳回";
                }
		    return '<a href="${ctx}/test/componentApplication/form?applicationCode='+row.applicationCode+'" class="btnList" data-title="${text('编辑component_application')}">'+(val||row.id)+'</a>';
		}},
		// {header:'${text('装配设备编号')}', name:'equipCode', index:'a.equip_code', width:150, align:"left"},
		{header:'${text('申领人')}', name:'extend.extendS2', index:'', width:150, align:"left"},
		{header:'${text('审批人')}', name:'testUser.userName', index:'', width:150, align:"left"},
		//{header:'${text('apply_sort')}', name:'applySort', index:'a.apply_sort', width:150, align:"center"},
		//{header:'${text('申领数量')}', name:'applicationNumber', index:'a.application_number', width:150, align:"center"},
		{header:'${text('申领原因')}', name:'applicationReason', index:'a.application_reason', width:150, align:"left"},
		{header:'${text('申请时间')}', name:'createDate', index:'a.create_date', width:150, align:"center"},
		//{header:'${text('申领完成时间')}', name:'applicationEndDate', index:'a.application_end_date', width:150, align:"center"},
		{header:'${text('申领状态')}', name:'applicationStatus', index:'a.application_status', width:150, align:"left"},
		// {header:'${text('状态')}', name:'status', index:'a.status', width:150, align:"center", formatter: function(val, obj, row, act){
		// 	return js.getDictLabel(${@DictUtils.getDictListJson('sys_search_status')}, val, '${text('未知')}', true);
		// }},
		//{header:'${text('创建时间')}', name:'createDate', index:'a.create_date', width:150, align:"center"},
		{header:'${text('备注信息')}', name:'remarks', index:'a.remarks', width:150, align:"left"},
		{header:'${text('操作')}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('test:componentApplication:edit')){ %>
                    if(row.applicationStatus == '审核通过'){
                        <%if(hasPermi('test:componentApplication:view')){%>
                            actions.push('<a href="${ctx}/test/componentApplication/form?applicationCode='+row.applicationCode+'&opera=view" class="btnList" title="${text('查看')}"><i class="fa fa-eye"></i></a>&nbsp;');
                        <% } %>
                    }
                    else {
                actions.push('<a href="${ctx}/test/componentApplication/form?applicationCode='+row.applicationCode+'" class="btnList" title="${text('编辑')}"><i class="fa fa-pencil"></i></a>&nbsp;');
				// if (row.status == Global.STATUS_NORMAL){
				// 	actions.push('<a href="${ctx}/test/componentApplication/disable?applicationCode='+row.applicationCode+'" class="btnList" title="${text('停用component_application')}" data-confirm="${text('确认要停用该component_application吗？')}"><i class="glyphicon glyphicon-ban-circle"></i></a>&nbsp;');
				// }
				// if (row.status == Global.STATUS_DISABLE){
				// 	actions.push('<a href="${ctx}/test/componentApplication/enable?applicationCode='+row.applicationCode+'" class="btnList" title="${text('启用component_application')}" data-confirm="${text('确认要启用该component_application吗？')}"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');
				// }
				actions.push('<a href="${ctx}/test/componentApplication/delete?applicationCode='+row.applicationCode+'" class="btnList" title="${text('删除')}" data-confirm="${text('确认要删除该备品备件吗？')}"><i class="fa fa-trash-o"></i></a>&nbsp;');
			   }
			<% } %>
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>